class ScorePanel{
    score = 0;
    level = 1;
    scoreEle:HTMLElement;
    levelEle:HTMLElement;
    maxLevel:number;
    maxScore:number;
    constructor(maxLevel:number = 10,maxScore:number = 10) { //等级上限  如果不传参 默认10
        this.maxLevel = maxLevel;   //maxLevel 最大等级
        this.maxScore = maxScore;   //maxScore 多少分升一级

        //分数
        this.scoreEle = document.querySelector('#score')!;
        //等级
        this.levelEle = document.querySelector('#level')!;
    }
    //加分
    addScore(){
        this.scoreEle.innerHTML = ++this.score+''
        //升级
        if(this.score % this.maxLevel == 0){
            this.levelUp()
        }
    }
    // 加等级
    levelUp(){
        //等级上限
        if(this.level < this.maxLevel){
            this.levelEle.innerHTML = ++this.level+''
        }
    }




}
export default ScorePanel;